import { Component, OnDestroy } from '@angular/core';

import { DoubleBrandProductService } from './double.brand.product.service';

import { ProductBase } from '../../product/product.base';

import { Util } from '../../../utils/util';


import { ToastyService } from '../../../modules/ng2-toasty';

@Component({
  selector: 'double-brand-product',
  templateUrl: './double.brand.product.html',
  providers: [DoubleBrandProductService]
})

export class DoubleBrandProductComponent extends ProductBase {

  brandInfo: any;

  param: any = {
    brandName: '',

    rows: 10,

    start: 0
  };


   // 列表
  public columns:Array<any> = [
  {
    title: '商品',
    name: 'brandName',
    sort: false,
    class:'productTh'
  },
  {
    title: '标题',
    name: 'categoryName',
    sort: false,
    class:'titleTh'
  },
  {
    title: '品牌',
    name: 'shopNum',
    sort: false
  },
  {
    title: '销售量',
    name: 'sellAmount',
    sort: true
  },
  {
    title: '预售价',
    name: 'priceYuShou',
    sort: true
  },
  {
    title: '定金',
    name: 'dingJin',
    sort: true
  }
  ];
  constructor(public util: Util, public service: DoubleBrandProductService,public toastyService:ToastyService) {
    super(service,util,toastyService);

    this.brandInfo = this.util.sessionStore().get('brandDetail');

    // console.log(this.brandInfo);
    this.param.brandName = this.brandInfo.brandName;

    this.getHttp(this.param);

  }

  ngOnDestroy(){
    if(this.busy){
      this.busy.unsubscribe();
    }
  }

  date:any;
  getHttp(param) {
    var res = {"code":0,"msg":"成功","data":{"value":[{"numberId":547548114586,"title":"【预售】New Balance/NB 373系列女休闲运动鞋WL373PP","picUrl":"//img.alicdn.com/imgextra/i2/520557274/TB16D3eXBTH8KJjy0FiXXcRsXXa_!!0-item_pic.jpg","loc":null,"propertyValue":"品牌:NEW BALANCE,鞋码:35 36 36.5 37 37.5 38 39 40,外底材料:橡胶,是否瑕疵:否,性别:女子,上市时间:2017年夏季,运动系列:女鞋-复古鞋,款号:2017Q2WL373PP,功能:减震 耐磨 包裹性,颜色分类:浅粉红色,帮面材质:牛剖层革+织物+人造革,适合路面:小道 公路,是否商场同款:是,流行元素:车缝线,吊牌价:519,闭合方式:系带","brandName":"new balance","sellAmount":34080,"priceYuShou":259.0,"dingJin":30.0,"diKou":50.0,"category":50012036,"uid":520557274,"modifyTime":1510049214000},{"numberId":547571999211,"title":"【预售】New Balance 373系列 女鞋复古鞋跑步鞋运动鞋WL373CR","picUrl":"//img.alicdn.com/imgextra/i2/520557274/TB1SfEfXsjI8KJjSsppXXXbyVXa_!!0-item_pic.jpg","loc":null,"propertyValue":"品牌:NEW BALANCE,鞋码:35 36 36.5 37 37.5 38 39 40,外底材料:橡胶,是否瑕疵:否,性别:女子,上市时间:2017年夏季,运动系列:女鞋-复古鞋,款号:2017Q2WL373CR,功能:减震 耐磨 包裹性,颜色分类:灰白色,帮面材质:牛剖层革+织物+人造革,适合路面:小道 公路,是否商场同款:是,流行元素:车缝线,吊牌价:519,闭合方式:系带","brandName":"new balance","sellAmount":16338,"priceYuShou":259.0,"dingJin":30.0,"diKou":50.0,"category":50012036,"uid":520557274,"modifyTime":1509964636000},{"numberId":522682828279,"title":"【预售】New Balance/NB 368系列 男女鞋跑步鞋休闲运动鞋M368LBR","picUrl":"//img.alicdn.com/imgextra/i2/520557274/TB2yYXWogMPMeJjy1XbXXcwxVXa-520557274.jpg","loc":"江苏苏州","propertyValue":"品牌:NEW BALANCE,鞋码:42.5 38 44 43 38.5 45 41.5 42 40 46.5 37.5 40.5 39.5,鞋帮高度:低帮,是否瑕疵:否,性别:男女通用,上市时间:2014年秋季,鞋底材质:橡胶,运动系列:中性鞋-复古鞋,款号:2014Q3M368LBK,功能:包裹性 减震 耐磨,颜色分类:黑色 深蓝色 深棕色,帮面材质:人造革,是否商场同款:是,流行元素:车缝线,吊牌价:519,闭合方式:系带","brandName":"new balance","sellAmount":14727,"priceYuShou":259.0,"dingJin":30.0,"diKou":50.0,"category":50012043,"uid":520557274,"modifyTime":1509094173000},{"numberId":543434606034,"title":"【预售】New Balance/NB 515系列男女鞋跑步鞋休闲运动鞋ML515COM","picUrl":"//img.alicdn.com/imgextra/i4/520557274/TB1z.W6XIL85uJjSZFrXXXdDXXa_!!0-item_pic.jpg","loc":"江苏苏州","propertyValue":"品牌:NEW BALANCE,外底材料:橡胶,是否瑕疵:否,性别:男女通用,上市时间:2017年春季,运动系列:中性鞋-复古鞋,款号:2017Q1ML515COM,功能:减震 耐磨 包裹性,颜色分类:黑色,帮面材质:织物+牛剖层革+人造革,适合路面:小道 公路,是否商场同款:是,流行元素:车缝线,吊牌价:559,闭合方式:系带","brandName":"new balance","sellAmount":13665,"priceYuShou":279.0,"dingJin":30.0,"diKou":50.0,"category":50012036,"uid":520557274,"modifyTime":1509964636000},{"numberId":559065196971,"title":"【预售】New Balance/NB 996系列男女鞋休闲鞋运动鞋MRL996MP","picUrl":"//img.alicdn.com/imgextra/i1/520557274/TB2yOldacjI8KJjSsppXXXbyVXa-520557274.jpg","loc":"江苏苏州","propertyValue":"品牌:NEW BALANCE,鞋码:40 42 43 41.5 44 36 42.5 37.5 39.5 38 37 40.5 38.5 45,外底材料:橡胶,是否瑕疵:否,性别:男女通用,上市时间:2017年冬季,运动系列:中性鞋-复古鞋,款号:2017Q4MRL996MU,功能:减震 耐磨 包裹性,颜色分类:米白色 蓝色 黑色,帮面材质:猪皮革+人造革,适合路面:小道 公路,是否商场同款:是,流行元素:车缝线,吊牌价:819,闭合方式:系带","brandName":"new balance","sellAmount":12398,"priceYuShou":399.0,"dingJin":40.0,"diKou":60.0,"category":50012036,"uid":520557274,"modifyTime":1509964636000},{"numberId":45750381076,"title":"【预售】New Balance/NB 373系列男鞋女鞋休闲运动鞋ML373AA/AB","picUrl":"//img.alicdn.com/imgextra/i3/520557274/TB2padvobsTMeJjy1zbXXchlVXa-520557274.jpg","loc":"江苏苏州","propertyValue":"品牌:NEW BALANCE,外底材料:橡胶,是否瑕疵:否,运动鞋科技:耐磨橡胶外底,性别:男女通用,上市时间:2015年秋季,运动系列:男鞋-复古鞋,款号:2015Q3ML373AA,功能:减震 耐磨 包裹性,颜色分类:灰蓝色 藏蓝色 酒红色,帮面材质:织物,适合路面:小道 公路,是否商场同款:是,流行元素:车缝线,吊牌价:519,闭合方式:系带","brandName":"new balance","sellAmount":12214,"priceYuShou":259.0,"dingJin":30.0,"diKou":50.0,"category":50012036,"uid":520557274,"modifyTime":1509094173000},{"numberId":43793759415,"title":"【预售】New Balance/NB 368系列 男鞋跑步鞋运动休闲鞋M368JBK","picUrl":"//img.alicdn.com/imgextra/i3/520557274/TB1mrOppRUSMeJjy1zkXXaWmpXa_!!0-item_pic.jpg","loc":"江苏苏州","propertyValue":"品牌:NEW BALANCE,鞋码:40 40.5 41.5 42 42.5 43 44 45,外底材料:橡胶,是否瑕疵:否,性别:男子,上市时间:2015年春季,运动系列:男鞋-复古鞋,款号:2015Q1M368AN,功能:减震 耐磨 包裹性,颜色分类:黑色 深棕色,帮面材质:人造革+织物,适合路面:小道 公路,是否商场同款:是,流行元素:车缝线,吊牌价:519,闭合方式:系带","brandName":"new balance","sellAmount":8907,"priceYuShou":259.0,"dingJin":30.0,"diKou":50.0,"category":50012036,"uid":520557274,"modifyTime":1509094173000},{"numberId":45770516761,"title":"【预售】New Balance/NB 373系列 女鞋复古跑步鞋 休闲鞋WL373AE","picUrl":"//img.alicdn.com/imgextra/i2/520557274/TB20NFCjvNNTKJjSspeXXaSwpXa-520557274.jpg","loc":"江苏苏州","propertyValue":"品牌:NEW BALANCE,鞋码:36 38 37.5 36.5 40 35 37 39,外底材料:橡胶,是否瑕疵:否,运动鞋科技:耐磨橡胶外底,性别:女子,上市时间:2015年秋季,运动系列:女鞋-复古鞋,款号:2015Q3WL373AD,功能:减震 耐磨 包裹性,颜色分类:藏青色 墨绿色,帮面材质:织物+人造革  人造革+织物,适合路面:小道 公路,是否商场同款:是,吊牌价:519,闭合方式:系带","brandName":"new balance","sellAmount":8439,"priceYuShou":259.0,"dingJin":30.0,"diKou":50.0,"category":50012036,"uid":520557274,"modifyTime":1509964636000},{"numberId":543483093650,"title":"【预售】New Balance 515系列男鞋女鞋跑步鞋休闲运动鞋ML515COL","picUrl":"//img.alicdn.com/imgextra/i3/520557274/TB1DCM1XaLN8KJjSZFvXXXW8VXa_!!0-item_pic.jpg","loc":null,"propertyValue":"品牌:NEW BALANCE,外底材料:橡胶,是否瑕疵:否,性别:男女通用,上市时间:2017年春季,运动系列:中性鞋-复古鞋,款号:2017Q1ML515COL,功能:透气 包裹性 轻便,颜色分类:灰色,帮面材质:织物+牛剖层格+人造革,适合路面:小道 公路 跑道,是否商场同款:是,流行元素:皮革拼接,吊牌价:559,闭合方式:系带","brandName":"new balance","sellAmount":8082,"priceYuShou":259.0,"dingJin":30.0,"diKou":50.0,"category":50012036,"uid":520557274,"modifyTime":1510049214000},{"numberId":559113935332,"title":"【预售】New Balance/NB 男针织上衣 运动休闲卫衣 AMT73591","picUrl":"//img.alicdn.com/imgextra/i1/520557274/TB2r8EeXsbI8KJjy1zdXXbe1VXa-520557274.jpg","loc":"江苏苏州","propertyValue":"品牌:NEW BALANCE,上市时间:2017年冬季,运动户外项目:运动休闲,款号:AMT73591,服装款式细节:品牌LOGO,领型:连帽,颜色分类:AG PGM BK,是否商场同款:是,吊牌价:429,穿着方式:套头,尺码:S(成人） M(成人） L(成人） XL(成人） XXL(成人）,性别:男","brandName":"new balance","sellAmount":7790,"priceYuShou":214.0,"dingJin":30.0,"diKou":50.0,"category":50011717,"uid":520557274,"modifyTime":1509533422000}],"count":348}};
    setTimeout(() => {

      this.vm.table.products = res.data.value;

      this.vm.table.count = res.data.count;

      if(this.vm.table.products.length>0){
        this.date = this.vm.table.products[0].modifyTime;
      }
    }, 100);
  }


  export(){


    let dim = ['modifyTime','numberId','title','picUrl','loc','propertyValue','brandName','sellAmount','priceYuShou','dingJin','diKou','uid'];

    let dimText = ['时间','宝贝Id','宝贝标题','宝贝图片链接','地址','属性','品牌名','销售量','预售价','定金','抵扣','店铺id'];

    let fileName = this.brandInfo.brandName+"全部预售宝贝";
    this.productExport(this.param,dim,dimText,fileName);
  }

}
